import {$get, $post,$get1} from '../utils/request.ts'
import { ElNotification } from 'element-plus'
//import {md5} from 'md5js'

//登陆方法
export  const $Login=async (params:object)=>{
    //params.password=md5(params.password,32)
    let ret= await $post('api/login',params)
    if(ret.code==200){
        //登陆成功后将token信息保存到浏览器缓存
        sessionStorage.setItem('token',ret.token=ret.token.substring(7))
        ElNotification({
            title: '通知',
            message:ret.msg,
            type: 'success',
        })
        return true
    }else{
        ElNotification({
            title: '通知',
            message:'登陆失败',
            type: 'error',
        })
        return false
    }
}

//获取一个账户
export const $getOne=async(params:object)=>{
    let ret=await $get('my/getUserInfo',params)
    console.log(ret)
    return ret
}